package org.jeecg.attachment.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.attachment.dto.req.DownloadFileReqDto;
import org.jeecg.attachment.dto.req.UploadFileModel;
import org.jeecg.attachment.entity.SysAttachment;
import org.jeecg.common.api.vo.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * 攻防工具附件表
 * @author: qiang.zhou
 * @date: 2024/9/6 10:17
 **/
public interface ISysAttachmentService extends IService<SysAttachment> {

    /**
     * 上传文件
     * @author: qiang.zhou
     * @date: 2024/9/6 10:49
     * @param fileModel
     * @return org.jeecg.common.api.vo.Result<?>
     **/
    Result<Long> uploadFile(UploadFileModel fileModel);

    /**
     * 上传文件
     * @author: qiang.zhou
     * @date: 2024/9/10 14:50
     * @param fileSize
     * @param fileName
     * @param md5
     * @param fileNo
     * @param inputStream
     * @return org.jeecg.common.api.vo.Result<java.lang.Long>
     **/
    Result<Long> uploadFile(long fileSize, String userId, String fileName, String md5, String fileNo, InputStream inputStream);

    /**
     * 上传文件
     * @author: qiang.zhou
     * @date: 2024/9/10 14:50
     * @param fileSize
     * @param fileName
     * @param fileNo
     * @param inputStream
     * @return org.jeecg.common.api.vo.Result<java.lang.Long>
     **/
    Result<Long> uploadTendFile(long fileSize, String userId, String fileName, String fileNo, InputStream inputStream);

    /**
     * 上传文件
     * @author: qiang.zhou
     * @date: 2024/9/10 14:50
     * @param file
     * @param userId
     * @param fileNo
     * @return org.jeecg.common.api.vo.Result<java.lang.Long>
     **/
    Result<Long> uploadFile(File file, String userId, String fileNo);


    /**
     * 上传文件
     * @author: qiang.zhou
     * @date: 2024/9/10 14:50
     * @param file
     * @param userId
     * @param fileNo
     * @return org.jeecg.common.api.vo.Result<java.lang.Long>
     **/
    Result<Long> uploadTendFile(File file, String userId, String fileNo);

    /**
     * 上传文件
     * @author: qiang.zhou
     * @date: 2024/9/10 14:50
     * @param txtJson
     * @return org.jeecg.common.api.vo.Result<java.lang.Long>
     **/
    Result<Long> uploadTendFile(String txtJson, String startTime, String endTime);

    /**
     * 下载文件
     * @author: qiang.zhou
     * @date: 2024/11/29 14:16
     * @param fileToken
     * @param response
     * @return void
     **/
    void downloadFile(String fileToken, HttpServletResponse response) throws Exception;

    /**
     * 图片类文件下载，
     * @author: qiang.zhou
     * @date: 2024/9/19 15:06
     * @param reqDto
     * @param response
     * @return org.jeecg.common.api.vo.Result<?>
     **/
    void downloadImage(DownloadFileReqDto reqDto, HttpServletResponse response) throws Exception;

    /**
     * 获取附件直链
     * @author: qiang.zhou
     * @date: 2024/11/29 13:48
     * @param reqDto
     * @return org.jeecg.common.api.vo.Result<java.lang.String>
     **/
    Result<String> getFileUrl(DownloadFileReqDto reqDto);

    /**
     * 根据id同时获取多个附件名称
     * @author: qiang.zhou
     * @date: 2024/12/3 15:21
     * @param attachmentIds
     * @return java.util.Map<java.lang.String,java.lang.String>
     **/
    Map<String, String> attachmentMap(List<String> attachmentIds);

    /**
     * 上传图片文件夹
     *  返回map: key:图片名称;value:文件id
     * @author: qiang.zhou
     * @date: 2024/12/10 16:02
     * @param image
     * @param userId
     * @return java.util.Map<java.lang.String,java.lang.String>
     **/
    Map<String, Long> uploadImageDirectory(File image, String userId, String fileNo, StringBuilder errorMsg);

}
